# -*- coding: utf-8 -*-
# @Time: 2021/8/13 15:20
# @File: problem-876.py
# @DESC: https://leetcode-cn.com/problems/reverse-linked-list/
# 反转链表

from list_node_common import ListNode, listToNode


class Solution:
    def reverseList(self, head: ListNode) -> ListNode:

        cur = head

        nHead = None

        while cur:
            next = cur.next
            temp = cur
            temp.next = nHead
            nHead = temp
            cur = next
        return nHead




data = [1, 2, 3, 4, 5]
l = listToNode(data)
so = Solution()
result = so.reverseList(l)
print()
